package com.zzz.gp.task;

import com.zzz.gp.dao.GpMapper;
import com.zzz.gp.service.analyse.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * @description:
 * @author: ZZZ
 * @time: 2021/12/14 16:22
 */
@Slf4j
@Component
public class AnalyseTask {
    @Autowired
    private A1Service A1;
    @Autowired
    private A2Service A2;
    @Autowired
    private A3Service A3;
    @Autowired
    private A4Service A4;
    @Autowired
    private A5Service A5;
    @Autowired
    private A17Service A17;
    @Autowired
    private V17Service V17;
    @Autowired
    private ADailyLimit1Service aDailyLimit1Service;
    @Autowired
    private ADailyLimit2Service aDailyLimit2Service;
    @Autowired
    private ADailyLimit3Service aDailyLimit3Service;

    @Autowired
    private LPService lp;
    @Autowired
    private GpMapper gpMapper;
    @Value("${analyse.enable}")
    private boolean enable;

    @Autowired
    private RiseProportionService riseProportionService;

    @Scheduled(cron = "${analyse.cron}")
    public void todayTask() {
        if (enable) {
            DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
            String today = dtf.format(LocalDate.now());
            Integer todayDataCount = gpMapper.getTodayDataCount(today);
            if (todayDataCount < 100) {
                log.info("today no data");
                return;
            }
            //A1.init();
            //A2.init();
            //A3.init();
            //A4.init();
            //A5.init();
            //A17.init();
            //V17.init();
            lp.init();  //跌且红
            aDailyLimit1Service.init();
            //aDailyLimit2Service.init();
            //aDailyLimit3Service.init();
            riseProportionService.todayRiseProportionSum();

        }
    }
}
